version			14
clear			all
set				more off

/* THE FILE GENERATES FIGURE A.I PANEL B OF WASEEM (2019) RESTAT */

matrix 			input tax_rates=(0.5 ,1   ,   2,  3,  4,  5,7.5,10 ,12.5,15,19,21  ,  25, 0, 0, 0  ,    0,   0, 0, 0\						///
								 0.25,0.5 ,0.75,1.5,2.5,3.5,4.5,6  , 7.5, 9,10,11  ,12.5,14,15,16  , 17.5,18.5,19,20\						///	
								 0.5 ,0.75,1.5 ,2.5,3.5,4.5,6  ,7.5,   9,10,11,12.5,	 14,15,16,17.5,	18.5,  19,20, 0\						///
								 1.5 ,2.5,3.5,4.5,6  ,7.5,   9,10,11,12.5,	 14,15,16,17.5,	18.5,  20, 0,0,0,0)

set				obs 7000
g				taxableinc=_n/10
expand			6
sort			taxableinc
egen			year=fill(2006 2007 2008 2009 2010 2011 2006 2007 2008 2009 2010 2011)
g				tau=0
local 			i=1
foreach 		z in 150 200 250 300 350 400 500 600 700 850 950 1050 1200 1500 1700 2000 3150 3700 4450 8400 {
					replace tau=tax_rates[2,`i'] if taxableinc > (`z') & (year==2006 | year==2007)
					local i=`i'+1
}
local 			i=1
foreach 		z in 180 250 350 400 450 550 650 750 900 1050 1200 1450 1700 1950 2250 2850 3550 4550 8650 {
					replace tau=tax_rates[3,`i'] if taxableinc > (`z') & (year==2008  | year==2009 | year==2010)
					local i=`i'+1
}
local 			i=1
foreach 		z in 350 400 450 550 650 750 900 1050 1200 1450 1700 1950 2250 2850 3550 4550 {
					replace tau=tax_rates[4,`i'] if taxableinc > (`z') & year==2011
					local i=`i'+1
}
replace  		tau=0.5  if taxableinc >200  & taxableinc<=250  & year==2009
replace  		tau=0  if taxableinc <= 200 & year==2009
replace  		tau=0  if taxableinc <= 300  & year==2010
replace  		tau=0  if taxableinc <= 350 & year==2011
replace 		tau=. if taxableinc==.
replace 		tau=0 if taxableinc<=0
reshape 		wide tau, i(taxableinc) j(year)

/* 2006-08 */

#d				;
twoway  		(line  tau2007 taxableinc,sort clcolor(teal) lwidth(thick))
				(line  tau2008 taxableinc,sort clcolor(brown) lwidth(thick) lpattern(longdash)),
				xtitle(Taxable Income in PKR 000s) xtitle(, alignment(top))
				xlabel(0(100)700) ylabel(0(1.5)6)
				ytitle(Average Tax Rate (%)) yscale(titlegap(*10))
				legend(region(style(none)) label(1 "2006-07") label(2 "2008") rows(1)) 
				graphregion(fcolor(white) style(none) color(white) margin(0 2 0 2)) bgcolor(white);
graph 			export "$project_graph\FigureAIPanelB.eps", replace;
#d 				cr

/* 2008-09 */

#d				;
twoway  		(line  tau2008 taxableinc,sort clcolor(brown) lwidth(thick) lpattern(longdash))
				(line  tau2009 taxableinc,sort clcolor(navy) lwidth(thick)),
				xtitle(Taxable Income in PKR 000s) xtitle(, alignment(top))
				xlabel(0(100)700) ylabel(0(1.5)6)
				ytitle(Average Tax Rate (%)) yscale(titlegap(*10))
				legend(region(style(none)) label(1 "2008") label(2 "2009") rows(1)) 
				graphregion(fcolor(white) style(none) color(white) margin(0 2 0 2)) bgcolor(white);
graph 			export "$project_graph\FigureAIPanelC.eps", replace;
#d 				cr

/* 2009-10 */

#d				;
twoway  		(line  tau2009 taxableinc,sort clcolor(navy) lwidth(thick))
				(line  tau2010 taxableinc,sort clcolor(maroon)  lwidth(thick) lpattern(longdash))
				(line  tau2011 taxableinc,sort clcolor(green)  lwidth(thick) lpattern(shortdash)),
				xtitle(Taxable Income in PKR 000s) xtitle(, alignment(top))
				xlabel(0(100)700) ylabel(0(1.5)6)
				ytitle(Average Tax Rate (%)) yscale(titlegap(*10))
				legend(region(style(none)) label(1 "2009") label(2 "2010") label(3 "2011") rows(1)) 
				graphregion(fcolor(white) style(none) color(white) margin(0 2 0 2)) bgcolor(white);
graph 			export "$project_graph\FigureAIPanelD.eps", replace;
#d 				cr
